<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var test1 = {name:'华为p60',price:8488,num:2};
        var num1 = 100;
        var strs = 'hello world';
        var test2 = [1,2,3,4];

        // 增加 

        // window.localStorage.setItem('test1',test1);
        // window.localStorage.setItem('num1',num1);
        // window.localStorage.setItem('strs',strs);
        // window.localStorage.setItem('test2',test2);

        // 取出  

        // console.log(typeof window.localStorage.getItem('test2'));
        // console.log(window.localStorage.getItem('test2'));

        //修改  
        // window.localStorage.setItem('test1',JSON.stringify(test1));
        // console.log(typeof window.localStorage.getItem('test1'));

        // console.log(JSON.parse(window.localStorage.getItem('test1')));

        // 删除1个  
        // console.log(window.localStorage.getItem('test1'))
        // window.localStorage.removeItem('test1');
        // console.log(window.localStorage.getItem('test1'))
        // 删除全部 
        window.localStorage.clear();
        console.log(window.localStorage.getItem('num1'))

    </script>
</body>
</html>